import React from "react";

class UncontrolledComponent extends React.Component {

    // eslint-disable-next-line no-useless-constructor
    constructor() {
        super();

        // 创建ref
        this.txtRef = React.createRef();
    }

    // 获取文本框的值
    getTxt = () =>{
        console.log(this.txtRef.current.value)
    }

    render() {
        return(
            <div>
                <input type="text" ref={this.txtRef}/>
                <button onClick={this.getTxt}>获取值</button>
            </div>
        )
    }
}

export default UncontrolledComponent;